package com.harmonk.firstscene.db.repository

import com.harmonk.firstscene.db.dao.PersonDao
import com.harmonk.firstscene.db.entity.Person
import kotlinx.coroutines.flow.Flow

class PersonRepository(private val personDao: PersonDao) {
    
    suspend fun getPersonById(id: Long): Person? = personDao.getPersonById(id)
    
    fun getPersonsByEventId(eventId: Long): Flow<List<Person>> = personDao.getPersonsByEventId(eventId)
    
    fun getPersonsByVehicleId(vehicleId: Long): Flow<List<Person>> = personDao.getPersonsByVehicleId(vehicleId)
    
    suspend fun insertPerson(person: Person): Long = personDao.insertPerson(person)
    
    suspend fun updatePerson(person: Person) = personDao.updatePerson(person)
    
    suspend fun deletePerson(person: Person) = personDao.deletePerson(person)
    
    suspend fun deletePersonsByEventId(eventId: Long): Int = personDao.deletePersonsByEventId(eventId)
}